#define ； ;
#define （ (
#define ） )

<?php  

/*这是第一个作业*/
$a="This is truth:\"php is the best language!\"";
$b="\$a是变量";
echo $a."<br>";
echo $b."<br>"."<br>"."<br>";



/*这是第二个作业*/
	$num=1000;
	$profit1=$num*(1+0.0225);
	$profit2=$profit1*(1+0.0279);
	$sum1="一年后年息：";
    $sum2="两年后本息：";
    echo $num."<br>";
    echo $sum1.$profit1."<br>";
    echo $sum2.$profit2."<br>"."<br>"."<br>";




/*这是第三个作业*/
  $pi="pi=3.14";
  $user="user=root";
  echo $pi."<br>";
  echo $user."<br>"."<br>"."<br>";


 /*这是求一元二次方程根*/


 function  root($a,$b,$c)
 {
 	$dirt=($b*$b)-(4*$a*$c);
 	if($dirt<0)
 		echo "it doesn't have true root"."<br>";
 	else
 		$p=(-$b)/(2*$a);
 	    $q=($dirt)/(2*$a);
 	    $x1=$p+$q;
 	    $x2=$p-$q;
 	    echo "x1=".$x1."<br>";
 	    echo "x2=".$x2."<br>"."<br>"."<br>";
 }


$a=1;
$b=4;
$c=2;
root($a,$b,$c);



/*遍历学生信息*/
$stu=array("number"=>23333333,"name"=>"迟总","sex"=>"男","tele"=>1536481567);

foreach ($stu as $key => $value) {
	echo $key.":".$value."<br>";
}

echo "<br>"."<br>"."<br>";

/*遍历商品信息*/
$goods=array(array("id"=>001,"name"=>"book","cost"=>"$50"),
	         array("id"=>002,"name"=>"bread","cost"=>"$5"),
	         array("id"=>003,"name"=>"bowl","cost"=>"$10"));

foreach ($goods as $key => $item) 
{

	echo "id:".$item["id"]."<br>";
	echo "name".$item["name"]."<br>";
	echo "cost".$item["cost"]."<br>"."<br>"."<br>";
		
}

/*计算某一天距2018.11.11的时间*/
  function mydate($year,$month,$day)
  { 
  	$nowyear=2018;/*其实我想获取当前年月日orz*/
  	$date=0;
  	for($year;$year<=($nowyear-1);$year++)/*计算输入年份到距2017年当天的时间*/
     {  if($year%4==0&&$year%100!=0||$year%400==0)
     	{
     		$date=$date+366;
     	}
     	else
        {
        	$date=$date+365;
        }
     }

    $nowmonth=11;
    if($month<=11)/*计算2017年当天到2018年10月当天的时间*/
    {	$date=$date+365;
        switch($month)
       {
        case 1:$date=$date+273;break;
        case 2:	$date=$date+242;break;
        case 3: $date=$date+214;break;
        case 4: $date=$date+183;break;
        case 5: $date=$date+153;break;
        case 6: $date=$date+122;break;
        case 7: $date=$date+92;break;
        case 8: $date=$date+61;break;
        case 9: $date=$date+30;break;
        case 10:$date=$date;break;
       }
    }
    else
    {
    	switch($month)
    	{
    		case 11:$date=$date+334;break;
    		case 12:$date=$date+304;break;
    	}
    }
    
    $nowday=11;
    if($day<=11)/*计算2018年10月当天到当下的时间*/
    {
    	$date=$date+31+($nowday-$day);
    }
    else
    {
    	$date=$date+31-($day-$nowday);
    }

 return $date;
}

echo  "date"."=".mydate(2008,10,1)."<br>"."<br>"."<br>";
 

 /*输出九九乘法表(阿拉伯数字版)*/
function   jiujiutable()
{ 	for($num=1;$num<=9;$num++)
 		for($numb=1,$change=1;$numb<=$num;$numb++,$change++)
 		{
 			$result=$num*$numb;
 			echo $num."*".$numb."=".$result."  ";
            if($change>=$num)
            	echo "<br>"."<br>"."<br>";
 		}
}

echo jiujiutable();

/*循环输出编号和成绩（看不懂也要硬做！！！）*/
function  stnum($num)
{   if($num=0)
	echo  "number"."="."0"."<br>";
	echo  "grade"."="."88"."<br>";
	if($num=1)
	echo  "number"."="."1"."<br>";
	echo  "grade"."="."60"."<br>";
	if($num=2)
	echo  "error!!!!!!"."<br>";
	if($num=3)
	echo  "number"."="."3"."<br>";
	echo  "grade"."="."99"."<br>";
	if($num=4)
	echo  "error!!!!!!"."<br>";
	if($num=5)
	echo  "number"."="."5"."<br>";
	echo  "grade"."="."66"."<br>";
}

function  circle($num)
{
    for($num;$num<=5;$num++)
    	{stnum($num);}
}

echo circle(1);


?>


